using SeataNet.Core.Common;

namespace SeataNet.Core.Model
{
    /// <summary>
    /// 全局事务上下文
    /// </summary>
    public class GlobalTransactionContext
    {
        /// <summary>
        /// 全局事务ID
        /// </summary>
        public string Xid { get; set; } = string.Empty;

        /// <summary>
        /// 事务类型
        /// </summary>
        public TransactionType TransactionType { get; set; }

        /// <summary>
        /// 事务状态
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 应用ID
        /// </summary>
        public string ApplicationId { get; set; } = string.Empty;

        /// <summary>
        /// 事务服务组
        /// </summary>
        public string TransactionServiceGroup { get; set; } = string.Empty;

        /// <summary>
        /// 事务名称
        /// </summary>
        public string TransactionName { get; set; } = string.Empty;

        /// <summary>
        /// 超时时间（毫秒）
        /// </summary>
        public int Timeout { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime BeginTime { get; set; }

        /// <summary>
        /// 应用数据
        /// </summary>
        public string? ApplicationData { get; set; }

        /// <summary>
        /// 是否为全局事务
        /// </summary>
        public bool IsGlobal => !string.IsNullOrEmpty(Xid);
    }
}